<!DOCTYPE html>


<html lang="en">
  

    <head>
      <meta charset="utf-8" />
        
      <meta
        name="viewport"
        content="width=device-width, initial-scale=1, maximum-scale=1"
      />
      <title>GBase8s备份策略备份程序部署查看 |  朝花夕拾</title>
  <meta name="generator" content="hexo-theme-ayer">
      
      <link rel="shortcut icon" href="/ww.ico" />
       
<link rel="stylesheet" href="/dist/main.css">

      
<link rel="stylesheet" href="/css/fonts/remixicon.css">

      
<link rel="stylesheet" href="/css/custom.css">
 
      <script src="https://cdn.staticfile.org/pace/1.2.4/pace.min.js"></script>
       
 

      <link
        rel="stylesheet"
        href="https://cdn.jsdelivr.net/npm/@sweetalert2/theme-bulma@5.0.1/bulma.min.css"
      />
      <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.0.19/dist/sweetalert2.min.js"></script>

      <!-- mermaid -->
      
      <style>
        .swal2-styled.swal2-confirm {
          font-size: 1.6rem;
        }
      </style>
    </head>
  </html>
</html>


<body>
  <div id="app">
    
      
    <main class="content on">
      <section class="outer">
  <article
  id="post-GBase8s备份策略备份程序部署查看"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h1 class="article-title sea-center" style="border-left:0" itemprop="name">
  GBase8s备份策略备份程序部署查看
</h1>
 

      
    </header>
     
    <div class="article-meta">
      <a href="/2023/05/10/GBase8s%E5%A4%87%E4%BB%BD%E7%AD%96%E7%95%A5%E5%A4%87%E4%BB%BD%E7%A8%8B%E5%BA%8F%E9%83%A8%E7%BD%B2%E6%9F%A5%E7%9C%8B/" class="article-date">
  <time datetime="2023-05-10T01:10:21.000Z" itemprop="datePublished">2023-05-10</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/GBase8s/">GBase8s</a>
  </div>
  
<div class="word_count">
    <span class="post-time">
        <span class="post-meta-item-icon">
            <i class="ri-quill-pen-line"></i>
            <span class="post-meta-item-text"> Word count:</span>
            <span class="post-count">617</span>
        </span>
    </span>

    <span class="post-time">
        &nbsp; | &nbsp;
        <span class="post-meta-item-icon">
            <i class="ri-book-open-line"></i>
            <span class="post-meta-item-text"> Reading time≈</span>
            <span class="post-count">3 min</span>
        </span>
    </span>
</div>
 
    </div>
      
    <div class="tocbot"></div>




  
    <div class="article-entry" itemprop="articleBody">
       
  <h1 id="GBase8s备份策略-x2F-备份程序-x2F-部署-x2F-查看"><a href="#GBase8s备份策略-x2F-备份程序-x2F-部署-x2F-查看" class="headerlink" title="GBase8s备份策略&#x2F;备份程序&#x2F;部署&#x2F;查看"></a>GBase8s备份策略&#x2F;备份程序&#x2F;部署&#x2F;查看</h1><h2 id="备份策略"><a href="#备份策略" class="headerlink" title="备份策略"></a>备份策略</h2><ul>
<li>每天晚上10点开始备份</li>
<li>周6是全量备份</li>
<li>周1&#x2F;2&#x2F;3&#x2F;4&#x2F;5和周日是增量备份</li>
<li>备份文件保留两周</li>
<li>备份文件存储目录： &#x2F;Gbase8sBackupDir&#x2F;$GBASEDBTSERVER</li>
</ul>
<h2 id="备份程序"><a href="#备份程序" class="headerlink" title="备份程序"></a>备份程序</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">!/bin/bash</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">filename: /Gbase8sBackupDir/shell/Gbase8sBackup.sh</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="keyword">function</span>: GBase 8s Database Server backup shell.</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">write by: liaosnet@gbasedbt.com 2022-09-05</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">update by : wangwei5@gbasedbt.com 2022-11-29</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">if [ &quot;X$1&quot; == &quot;X&quot; ] ; then</span><br><span class="line">	echo &quot;Environment variables are not loaded correctly.&quot;</span><br><span class="line">	exit 11</span><br><span class="line">fi</span><br><span class="line">. $1</span><br><span class="line"></span><br><span class="line">export LANG=C</span><br><span class="line">WORKDIR=/Gbase8sBackupDir/$GBASEDBTSERVER</span><br><span class="line">LOGFILE=$&#123;WORKDIR:-$(pwd)&#125;/backup_status.log</span><br><span class="line">[ ! -f $&#123;LOGFILE&#125; ] &amp;&amp; touch $&#123;LOGFILE&#125;</span><br><span class="line">loginfo()&#123;</span><br><span class="line">  echo -e &quot;[$(date +&#x27;%Y-%m-%d %H:%M:%S&#x27;)] $*&quot; &gt;&gt; $&#123;LOGFILE&#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">L0DAY=6</span><br><span class="line">L1DAY=0,1,2,3,4,5</span><br><span class="line">L2DAY=8</span><br><span class="line">KEEPDAYS=14</span><br><span class="line">USERNAME=gbasedbt</span><br><span class="line">DBSTATUS=$(onstat -c|grep &#x27;On-Line&#x27;|wc -l)</span><br><span class="line">BACKUPDIR=$WORKDIR</span><br><span class="line">CURRDAY=$(date +%w)</span><br><span class="line">HADBACKUP=$(onstat -g arc | awk &#x27;$1==&quot;name&quot;&#123;need=1&#125;need==1&amp;&amp;$3==&quot;0&quot;&#123;print &quot;1&quot;;exit&#125;&#x27;)</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># check env</span></span></span><br><span class="line">if [ ! x&quot;$(whoami)&quot; = &quot;x$&#123;USERNAME&#125;&quot; ]; then</span><br><span class="line">  loginfo &quot;Must run as user: $&#123;USERNAME&#125;&quot;</span><br><span class="line">  exit 100</span><br><span class="line">fi </span><br><span class="line"></span><br><span class="line">if [ ! &quot;x$&#123;DBSTATUS&#125;&quot; = &quot;x1&quot; ]; then</span><br><span class="line">  loginfo &quot;Backup ONLY run On-Line Server which is Primary Server or Standard Server.&quot;</span><br><span class="line">  exit 4</span><br><span class="line">fi</span><br><span class="line"></span><br><span class="line">if [ ! -d $&#123;BACKUPDIR&#125; ];then</span><br><span class="line">  loginfo &quot;The Backup dir is not exists.&quot;</span><br><span class="line">  exit 3</span><br><span class="line">fi</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># backup db</span></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">delete file</span></span><br><span class="line">loginfo &quot;Delete files at $BACKUPDIR which out $&#123;KEEPDAYS:-30&#125; days.&quot;</span><br><span class="line">cd $BACKUPDIR &amp;&amp; find $BACKUPDIR -name &quot;*L[0-2]&quot; -type f -ctime +$&#123;KEEPDAYS:-30&#125; | xargs rm -rf</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">backup db</span></span><br><span class="line">if [ x&quot;$HADBACKUP&quot; = x ]; then</span><br><span class="line">  loginfo &quot;Execute L0 backup start, while no backup found.&quot;</span><br><span class="line">  CURRDAY=9</span><br><span class="line">  ontape -s -L 0</span><br><span class="line">fi</span><br><span class="line"></span><br><span class="line">if [[ $&#123;L0DAY&#125; =~ $&#123;CURRDAY&#125; ]]; then</span><br><span class="line">  loginfo &quot;Execute L0 backup start...&quot;</span><br><span class="line">  ontape -s -L 0</span><br><span class="line">elif [[ $&#123;L1DAY&#125; =~ $&#123;CURRDAY&#125; ]]; then</span><br><span class="line">  loginfo &quot;Execute L1 backup start...&quot;</span><br><span class="line">  ontape -s -L 1</span><br><span class="line">elif [[ $&#123;L2DAY&#125; =~ $&#123;CURRDAY&#125; ]]; then</span><br><span class="line">  loginfo &quot;Execute L2 backup start...&quot;</span><br><span class="line">  ontape -s -L 2</span><br><span class="line">fi</span><br><span class="line"></span><br><span class="line">if [ $? -eq 0 ];then</span><br><span class="line">  loginfo &quot;Execute backup finished.&quot;</span><br><span class="line">  exit 0</span><br><span class="line">else</span><br><span class="line">  loginfo &quot;Execute backup error.&quot;</span><br><span class="line">  exit 1</span><br><span class="line">fi</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>



<h2 id="部署备份程序"><a href="#部署备份程序" class="headerlink" title="部署备份程序"></a>部署备份程序</h2><h5 id="创建备份目录"><a href="#创建备份目录" class="headerlink" title="创建备份目录"></a>创建备份目录</h5><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">root用户执行：</span></span><br><span class="line">mkdir /Gbase8sBackupDir</span><br><span class="line">chown gbasedbt:gbasedbt /Gbase8sBackupDir</span><br><span class="line">su - gbasedbt</span><br></pre></td></tr></table></figure>

<h5 id="上传备份程序"><a href="#上传备份程序" class="headerlink" title="上传备份程序"></a>上传备份程序</h5><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">gbasedbt用户执行：</span></span><br><span class="line">onmode -wf TAPEDEV=/Gbase8sBackupDir/$GBASEDBTSERVER</span><br><span class="line">mkdir /Gbase8sBackupDir/$GBASEDBTSERVER</span><br><span class="line">mkdir /Gbase8sBackupDir/shell</span><br><span class="line">cat &gt; /Gbase8sBackupDir/shell/Gbase8sBackup.sh</span><br><span class="line">...把上面的备份程序整个复制粘贴到这里后，Ctrl+d 保存。</span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">gbasedbt用户执行：</span></span><br><span class="line">chmod 750 /Gbase8sBackupDir/shell/Gbase8sBackup.sh</span><br></pre></td></tr></table></figure>

<h5 id="部署定时任务"><a href="#部署定时任务" class="headerlink" title="部署定时任务"></a>部署定时任务</h5><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">gbasedbt用户执行：</span></span><br><span class="line">crontab -e</span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">0 22 * * *  /Gbase8sBackupDir/shell/Gbase8sBackup.sh /home/gbasedbt/.bash_profile &gt; /Gbase8sBackupDir/shell/Gbase8sBackup.log 2&gt;&amp;1 </span><br></pre></td></tr></table></figure>

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">:wq</span><br></pre></td></tr></table></figure>



<p>— 部署完成，等待时间，检测备份文件。</p>
<h2 id="检测备份情况"><a href="#检测备份情况" class="headerlink" title="检测备份情况"></a>检测备份情况</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">gbasedbt用户操作：</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># 检查ontape日志：</span></span></span><br><span class="line">cat /Gbase8sBackupDir/shell/Gbase8sBackup.log</span><br><span class="line">cat /Gbase8sBackupDir/$GBASEDBTSERVER/backup_status.log</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># 检查数据库日志：</span></span></span><br><span class="line">onstat -m</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># 检查arc命令：</span></span></span><br><span class="line">onstat -g arc</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment"># 检查备份文件：</span></span></span><br><span class="line">ls -lrt /Gbase8sBackupDir/$GBASEDBTSERVER</span><br></pre></td></tr></table></figure>

 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <div class="declare">
      <ul class="post-copyright">
        <li>
          <i class="ri-copyright-line"></i>
          <strong>Copyright： </strong>
          
          Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
          
        </li>
      </ul>
    </div>
    
    <footer class="article-footer">
       
<div class="share-btn">
      <span class="share-sns share-outer">
        <i class="ri-share-forward-line"></i>
        分享
      </span>
      <div class="share-wrap">
        <i class="arrow"></i>
        <div class="share-icons">
          
          <a class="weibo share-sns" href="javascript:;" data-type="weibo">
            <i class="ri-weibo-fill"></i>
          </a>
          <a class="weixin share-sns wxFab" href="javascript:;" data-type="weixin">
            <i class="ri-wechat-fill"></i>
          </a>
          <a class="qq share-sns" href="javascript:;" data-type="qq">
            <i class="ri-qq-fill"></i>
          </a>
          <a class="douban share-sns" href="javascript:;" data-type="douban">
            <i class="ri-douban-line"></i>
          </a>
          <!-- <a class="qzone share-sns" href="javascript:;" data-type="qzone">
            <i class="icon icon-qzone"></i>
          </a> -->
          
          <a class="facebook share-sns" href="javascript:;" data-type="facebook">
            <i class="ri-facebook-circle-fill"></i>
          </a>
          <a class="twitter share-sns" href="javascript:;" data-type="twitter">
            <i class="ri-twitter-fill"></i>
          </a>
          <a class="google share-sns" href="javascript:;" data-type="google">
            <i class="ri-google-fill"></i>
          </a>
        </div>
      </div>
</div>

<div class="wx-share-modal">
    <a class="modal-close" href="javascript:;"><i class="ri-close-circle-line"></i></a>
    <p>扫一扫，分享到微信</p>
    <div class="wx-qrcode">
      <img src="//api.qrserver.com/v1/create-qr-code/?size=150x150&data=http://example.com/2023/05/10/GBase8s%E5%A4%87%E4%BB%BD%E7%AD%96%E7%95%A5%E5%A4%87%E4%BB%BD%E7%A8%8B%E5%BA%8F%E9%83%A8%E7%BD%B2%E6%9F%A5%E7%9C%8B/" alt="微信分享二维码">
    </div>
</div>

<div id="share-mask"></div>  
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E5%A4%87%E4%BB%BD%E9%83%A8%E7%BD%B2/" rel="tag">备份部署</a></li></ul>

    </footer>
  </div>

   
  <nav class="article-nav">
    
      <a href="/2023/05/10/GBase8s%E7%9A%84Server%E5%92%8CCM%E7%9A%84%E6%97%A5%E5%BF%97%E6%8C%89%E5%A4%A9%E5%88%86%E7%89%87/" class="article-nav-link">
        <strong class="article-nav-caption">上一篇</strong>
        <div class="article-nav-title">
          
            GBase8s的Server和CM的日志按天分片
          
        </div>
      </a>
    
    
      <a href="/2023/05/10/%E5%85%A5%E9%97%A8-JAVA%E4%B9%8B%E8%B7%AF/" class="article-nav-link">
        <strong class="article-nav-caption">下一篇</strong>
        <div class="article-nav-title">入门-JAVA之路</div>
      </a>
    
  </nav>

  
   
  
    
</article>

</section>
      <footer class="footer">
  <div class="outer">
    <ul>
      <li>
        Copyrights &copy;
        2023-2024
        <i class="ri-heart-fill heart_icon"></i> Wang Wei
      </li>
    </ul>
    <ul>
      <li>
        
      </li>
    </ul>
    <ul>
      <li>
        
        
        <span>
  <span><i class="ri-user-3-fill"></i>Visitors:<span id="busuanzi_value_site_uv"></span></span>
  <span class="division">|</span>
  <span><i class="ri-eye-fill"></i>Views:<span id="busuanzi_value_page_pv"></span></span>
</span>
        
      </li>
    </ul>
    <ul>
      
    </ul>
    <ul>
      
    </ul>
    <ul>
      <li>
        <!-- cnzz统计 -->
        
      </li>
    </ul>
  </div>
</footer>    
    </main>
    <div class="float_btns">
      <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>

    </div>
    <aside class="sidebar on">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="/images/ww.ico" alt="朝花夕拾"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags">标签</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="Search">
        <i class="ri-search-line"></i>
      </a>
      
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/images/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/images/wechat.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/js/jquery-3.6.0.min.js"></script>
 
<script src="/js/lazyload.min.js"></script>

<!-- Tocbot -->
 
<script src="/js/tocbot.min.js"></script>

<script>
  tocbot.init({
    tocSelector: ".tocbot",
    contentSelector: ".article-entry",
    headingSelector: "h1, h2, h3, h4, h5, h6",
    hasInnerContainers: true,
    scrollSmooth: true,
    scrollContainer: "main",
    positionFixedSelector: ".tocbot",
    positionFixedClass: "is-position-fixed",
    fixedSidebarOffset: "auto",
  });
</script>

<script src="https://cdn.staticfile.org/jquery-modal/0.9.2/jquery.modal.min.js"></script>
<link
  rel="stylesheet"
  href="https://cdn.staticfile.org/jquery-modal/0.9.2/jquery.modal.min.css"
/>
<script src="https://cdn.staticfile.org/justifiedGallery/3.8.1/js/jquery.justifiedGallery.min.js"></script>

<script src="/dist/main.js"></script>

<!-- ImageViewer -->

<!-- MathJax -->

<!-- Katex -->

<!-- busuanzi  -->
 
<script src="/js/busuanzi-2.3.pure.min.js"></script>
 
<!-- ClickLove -->

<!-- ClickBoom1 -->

<!-- ClickBoom2 -->

<!-- CodeCopy -->
 
<link rel="stylesheet" href="/css/clipboard.css">
 <script src="https://cdn.staticfile.org/clipboard.js/2.0.10/clipboard.min.js"></script>
<script>
  function wait(callback, seconds) {
    var timelag = null;
    timelag = window.setTimeout(callback, seconds);
  }
  !function (e, t, a) {
    var initCopyCode = function(){
      var copyHtml = '';
      copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
      copyHtml += '<i class="ri-file-copy-2-line"></i><span>COPY</span>';
      copyHtml += '</button>';
      $(".highlight .code pre").before(copyHtml);
      $(".article pre code").before(copyHtml);
      var clipboard = new ClipboardJS('.btn-copy', {
        target: function(trigger) {
          return trigger.nextElementSibling;
        }
      });
      clipboard.on('success', function(e) {
        let $btn = $(e.trigger);
        $btn.addClass('copied');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-checkbox-circle-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPIED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-checkbox-circle-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
      clipboard.on('error', function(e) {
        e.clearSelection();
        let $btn = $(e.trigger);
        $btn.addClass('copy-failed');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-time-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPY FAILED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-time-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
    }
    initCopyCode();
  }(window, document);
</script>
 
<!-- CanvasBackground -->

<script>
  if (window.mermaid) {
    mermaid.initialize({ theme: "forest" });
  }
</script>


    
    

  </div>
</body>

</html>